package work20241224;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author zdl
 * @date 2024/12/24
 */
public class Demo2 {
    public static void main(String[] args) {
        ThreadPoolExecutor pool = new ThreadPoolExecutor(2, 4, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(5));
        Runnable run1 = new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i < 10; i++) {
                    for (int j = 1; j <= i; j++) {
                        System.out.print(j + "*" + i + "=" + j * i + "\t");
                    }
                    System.out.println();
                }
            }
        };
        Runnable run2 = new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i < 10; i++) {
                    for (int j = 1; j <= i; j++) {
                        System.out.print("*");
                    }
                    System.out.println();
                }
            }
        };
        pool.execute(run1);
        pool.execute(run2);
    }
}
